﻿using System;
using System.Web;

using BizElements.BusinessLayer;

namespace BizElements.Web
{
    /// <summary>Gets and parses common URL query-string values. Prefer using <see cref="WebFormContext"/> class which has a reacher set of functionalitiy 
    /// and may be adapted to use mechanisms other than query string. Eg: session state, POST variables etc.</summary>
    public static class CommonQueryValues
    {
        #region Extracts values from common query-string keys.

        ///// <summary>Gets number specified in <see cref="CommonQueryKeys.EntityId"/> parameter. Key: <b>id</b></summary>
        //public static long? EntityId
        //{
        //    get { return NumberParser.ParseLong(HttpContext.Current.Request.QueryString[CommonQueryKeys.EntityId]); }
        //}

        /// <summary>Gets string specified in <see cref="CommonQueryKeys.OnSuccessScript"/> parameter. Key: <b>onSuccess</b></summary>
        public static string OnSuccessScript
        {
            get { return HttpContext.Current.Request.QueryString[CommonQueryKeys.OnSuccessScript]; }
        }

        /// <summary>Gets string specified in <see cref="CommonQueryKeys.OnCancelScript"/> parameter. Key: <b>onCancel</b></summary>
        public static string OnCancelScript
        {
            get { return HttpContext.Current.Request.QueryString[CommonQueryKeys.OnCancelScript]; }
        }

        /// <summary>Gets string specified in <see cref="CommonQueryKeys.OnCloseScript"/> parameter. Key: <b>onClose</b></summary>
        public static string OnCloseScript
        {
            get { return HttpContext.Current.Request.QueryString[CommonQueryKeys.OnCloseScript]; }
        }

        /// <summary>Gets string specified in <see cref="CommonQueryKeys.OnCloseUrl"/> parameter. Key: <b>onCloseUrl</b></summary>
        public static string OnCloseUrl
        {
            get { return HttpContext.Current.Request.QueryString[CommonQueryKeys.OnCloseUrl]; }
        }

        #endregion
    } 
}
